/**
 * @Description : 文章标题配置
 * @author : August_xiao 1932794922@qq.com
 * @date : 2022-03-13 8:01
 */
import * as tocbot from 'tocbot'

const getBoxHeight = () => {
  $('.toc-container').css('height', $('#down-box').height())
}

tocbot.init({
  tocSelector: '.toc', // 放置目录的容器
  contentSelector: '#down-box', // 正文内容所在
  headingSelector: 'h1, h2, h3, h4, h5, h6', // 需要索引的标题级别
  // positionFixedSelector: '.toc',
  scrollSmoothOffset: -85,
  onClick: function (e) {
    if (e.preventDefault) {
      e.preventDefault()
    }
  },
  scrollEndCallback: function () {
    getBoxHeight()
  }
})

export { tocbot, getBoxHeight }
